﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Autodesk.Revit.DB;
using ModelCheckUtility.ModelLayer;

namespace ModelCheckUtility.ControlLayer
{
	public class BasePorgramArchitectural<X, BasePackerFinder, BasePackerChecker, BasePackerShower> where X : class, IResultPackerTag where BasePackerFinder : class, IPackerFind<X> where BasePackerChecker : class, IPackerCheck<X> where BasePackerShower : class, IPackerResutlShow<X>
	{
		public BasePorgramArchitectural(Assembly useAssembly, string useNameSpace, string cmdName, List<object> appendObject = null)
		{
			this.m_strCmdName = cmdName;
			BaseInterfaceFactory<X>.UseAssembly = useAssembly;
			BaseInterfaceFactory<X>.NameSpace = useNameSpace;
			this.m_UseFinder = BaseInterfaceFactory<X>.GetPackerFinder<BasePackerFinder>(cmdName, null);
			this.m_UseChecker = BaseInterfaceFactory<X>.GetPackerChecker<BasePackerChecker>(cmdName, null);
			this.m_UseShower = BaseInterfaceFactory<X>.GetPackerShower<BasePackerShower>(cmdName, null);
			this.m_lstAppendValues = appendObject;
		}

		public virtual void BaseDo(Document useDocument, params object[] appendValues)
		{
			this.m_lstFindedValues = this.FindPackers(useDocument, appendValues);
			if (this.m_lstFindedValues == null)
			{
				return;
			}
			this.m_lstCheckedValues = this.CheckPackers(this.m_lstFindedValues, appendValues);
			this.PackersShows(this.m_lstCheckedValues, appendValues);
		}

		protected virtual List<X> FindPackers(Document useDocument, params object[] appendValues)
		{
			return this.m_UseFinder.FindPackers(useDocument, appendValues);
		}

		protected virtual List<X> CheckPackers(List<X> inputValues, params object[] appendValues)
		{
			return this.m_UseChecker.CheckPackers(inputValues, appendValues);
		}

		protected virtual void PackersShows(List<X> inputValues, params object[] appendValues)
		{
			this.m_UseShower.ShowResults(inputValues, appendValues);
		}

		protected string m_strCmdName;

		protected BasePackerFinder m_UseFinder;

		protected BasePackerChecker m_UseChecker;

		protected BasePackerShower m_UseShower;

		protected List<object> m_lstAppendValues;

		protected List<X> m_lstFindedValues;

		protected List<X> m_lstCheckedValues;
	}
}
